/*
 * @Author: szx
 * @Date: 2021-10-19 13:31:30
 * @LastEditTime: 2021-10-19 13:48:39
 * @Description:
 * @FilePath: \leetcode\211\211.go
 */

package main

type WordDictionary struct {
	data []string
}

func Constructor() WordDictionary {
	return WordDictionary{data: make([]string, 0)}
}

func (this *WordDictionary) AddWord(word string) {
	this.data = append(this.data, word)
}

func (this *WordDictionary) Search(word string) bool {
	for _, d := range this.data {
		if len(d) != len(word) {
			continue
		}
		flag := true
		for i, w := range word {
			if w == '.' {
				continue
			}
			if string(d[i]) != string(w) {
				flag = false
				break
			}
		}
		if flag {
			return true
		}
	}
	return false
}

/**
 * Your WordDictionary object will be instantiated and called as such:
 * obj := Constructor();
 * obj.AddWord(word);
 * param_2 := obj.Search(word);
 */
